from typing import List, Union
from pydantic_settings import BaseSettings
import secrets


class Settings(BaseSettings):
    PROJECT_NAME: str = "Lost and Found System"
    VERSION: str = "1.0.0"
    API_V1_STR: str = "/api/v1"
    
    # Database settings
    MYSQL_USER: str = "root"
    MYSQL_PASSWORD: str = "Aqilmini886"
    MYSQL_HOST: str = "localhost"
    MYSQL_PORT: str = "3306"
    MYSQL_DB: str = "wx_app"
    
    # JWT settings
    SECRET_KEY: str = secrets.token_urlsafe(32)
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8  # 8 days
    
    # CORS settings
    BACKEND_CORS_ORIGINS: List[str] = ["*"]
    
    # WeChat settings
    WECHAT_APP_ID: str = "your_app_id"
    WECHAT_APP_SECRET: str = "your_app_secret"
    WECHAT_TOKEN: str = "your_token"
    WECHAT_ENCODING_AES_KEY: str = "your_encoding_aes_key"
    
    # Frontend URL
    FRONTEND_URL: str = "http://localhost:8000"
    
    @property
    def SQLALCHEMY_DATABASE_URI(self) -> str:
        return f"mysql+pymysql://{self.MYSQL_USER}:{self.MYSQL_PASSWORD}@{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DB}"
    
    class Config:
        case_sensitive = True


settings = Settings() 